<?php

class UserAction  extends CommonAction
{
	public function index()
	{
		$record=M('site');
		//dump($record->select());
		
		$list = $record->select();
		
		$this->assign('list',$list);
//		$aasa=D('ceshi');
//		print_r($aasa->brack());
		
		
		$this->display();	
	}
	
	public  function insert()
	{		
	    $Form	=	M("site");
		if($Form->create()) {
			if(false !==$Form->add()) {
    			$this->success('数据添加成功！');
            }else{
                $this->error('数据写入错误');
            }
		}else{
			header("Content-Type:text/html; charset=utf-8");
			exit($Form->getError().' [ <A HREF="javascript:history.back()">返 回</A> ]');
		}
	}
	
    public function record() 
    {
    	$siteid = $_REQUEST['siteid'];//获取网站ID
    	
    	//dump($siteid);
/*		$record=M('record');
		$record->create();
		//dump($record->select());		
		$wher['siteid']=$siteid;
		$list = $record->where($wher)->select();
		$domain=$_REQUEST['domain'];
		//dump($domain);
		$addtime = date("Y-m-d H:i:s",$list[$siteid][addtime]);
		//echo $addtime.'<br>';
		
		$this->assign('addtime',$addtime);
		$this->assign('domain',$domain);*/
    	$User = M("record"); // 实例化User对象
        import("ORG.Util.Page"); // 导入分页类
        $count = $User->where("siteid=$siteid")->count(); // 查询满足要求的总记录数
        $Page = new Page($count,10); // 实例化分页类传入总记录数和每页显示的记录数
        $show = $Page->show(); // 分页显示输出

        // 进行分页数据查询注意limit方法的参数要使用Page类的属性
        $whe['siteid']=$siteid;

        $list = $User->where($whe)->order('addtime')->limit($Page->firstRow.','.$Page->listRows)->select();
        //echo '<pre>';
        //print_r($list);
        //echo '<pre>';
        $this->assign('list',$list); // 赋值数据集 
        $this->assign('page',$show); // 赋值分页输出
		
		//$this->assign('list',$list);
		
		
		$this->display();

		
	}
	public function edit()
	{
		$record=M('site');
		//dump($record->select());
		
		$list = $record->select();
	
		
		$this->assign('list',$list);
		$this->display();		
	}
	
	public function save()
	{
	    $Form	=	M("site");
		if($Form->create()) {
			if(false !==$Form->save()) {
    			$this->success('数据添加成功！');
            }else{
                $this->error('数据写入错误');
            }
		}else{
			header("Content-Type:text/html; charset=utf-8");
			exit($Form->getError().' [ <A HREF="javascript:history.back()">返 回</A> ]');
		}
		
	}

}

?>